package com.wuhunyu.controller;

import com.wuhunyu.commonutils.result.CommonResult;
import com.wuhunyu.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 登录控制器
 *
 * @author wuhunyu
 * @version 1.0
 * @date 2021-02-02 11:24
 */
@RestController
@RequestMapping("/user")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    public CommonResult login(@RequestParam(value = "username") String username, @RequestParam("password") String password) {
        return loginService.login(username, password);
    }

    @PostMapping("/info")
    public CommonResult userInfo(@RequestParam("token") String token) {
        return loginService.userInfo(token);
    }

    @PostMapping("logout")
    public CommonResult logout() {
        return CommonResult.success("退出登录");
    }
}
